package com.star.demo;

import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * demo项目，主要是给人学习用
 *
 * @author zhouhengzhe
 * @version 1.0
 * @date 2023/12/1 17:11
 */
@Slf4j
@SpringBootApplication(scanBasePackages = "com.star")
@EnableKnife4j
@MapperScan("com.star.demo.repository.mapper")
@EnableAspectJAutoProxy(proxyTargetClass = true)
public class DemoApplication {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(DemoApplication.class, args);
        Environment env = application.getEnvironment();
        String appName = env.getProperty("spring.application.name");
        String appPort = env.getProperty("server.port");
        String localIp = InetAddress.getLocalHost().getHostAddress();
        String username = env.getProperty("knife4j.basic.username");
        String password = env.getProperty("knife4j.basic.password");
        log.info("\n----------------------------------------------------------\n\t" +
                        "Application '{}' is running! Access URLs:\n\t" +
                        "Local: \t\thttp://localhost:{}\n\t" +
                        "External: \thttp://{}:{}\n\t" +
                        "Doc: \thttp://{}:{}/doc.html\t" +
                        "账户名：{}\t"+
                        "密码：{}\t\n" +
                        "----------------------------------------------------------",
                appName,
                appPort,
                localIp, appPort,
                localIp, appPort,
                username,
                password);
    }
}